package com.ncr.travel.appmgr.client.event;

import com.google.gwt.event.shared.GwtEvent;
import com.ncr.travel.appmgr.model.shared.Rule;

public class RuleChangeEvent extends GwtEvent<RuleChangeHandler> {
	private static Type<RuleChangeHandler> TYPE = new Type<RuleChangeHandler>();

	private Rule rule;

	public RuleChangeEvent() {
	}

	public RuleChangeEvent(Rule rule) {
		this.rule = rule;
	}

	/**
	 * Gets the event type associated with load events.
	 * 
	 * @return the handler type
	 */
	public static com.google.gwt.event.shared.GwtEvent.Type<RuleChangeHandler> getType() {
		return TYPE;
	}

	/**
	 * @see com.google.gwt.event.shared.GwtEvent#dispatch(com.google.gwt.event.shared.EventHandler)
	 */
	@Override
	protected void dispatch(RuleChangeHandler handler) {
		handler.onRuleChanged(this);
	}

	protected void fire(HasRuleChangeHandlers source) {
		source.fireEvent(new RuleChangeEvent());
	}

	public static void fire(HasRuleChangeHandlers source, Rule rule) {
		source.fireEvent(new RuleChangeEvent(rule));
	}

	@Override
	public com.google.gwt.event.shared.GwtEvent.Type<RuleChangeHandler> getAssociatedType() {
		return TYPE;
	}

	public Rule getRule() {
		return rule;
	}

}
